test: migrate stats/base/dists/chi/pdf to ULP-based assertions - #14323
Merged
Conversation
Contributor
Coverage Report
The above coverage report was generated for the changes in this PR. |
kgryte
marked this pull request as ready for review
August 16, 2026 23:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves a part of #11352.
Description
This pull request:
stats/base/dists/chi/pdffrom relative tolerance testing (delta <= tol, wheretol = 140.0 * EPS * abs( expected[ i ] )) to ULP difference testing using@stdlib/assert/is-almost-same-value.Changes are limited to test files:
test/test.pdf.jstest/test.factory.jstest/test.native.jsIn each of the three fixture loops, the
if ( y === expected[i] ) { ... } else { delta/tol ... }branch was replaced withThe
@stdlib/assert/is-almost-same-valuerequire was added, and the now-unused@stdlib/math/base/special/absrequire (along with thedeltaandtollocals) was removed. The@stdlib/constants/float64/epsrequire is retained intest/test.pdf.jsandtest/test.factory.js, whereEPSis still used to generate negative input values, and removed fromtest/test.native.js, where it is no longer referenced.ULP constant
The measured minimum ULP value is 230, used in all three converted fixture loops:
test/test.pdf.jstest/test.factory.jstest/test.native.jsThe bound was tightened by measuring the exact worst-case ULP difference over the full Julia fixture set (
decimal_decimal.json, 5000 values). The maximum observed difference is exactly 230 ULP, and the suite fails at 229 (a single failing case), so 230 is the minimum admissible integer bound.Notably, the JavaScript implementation, the factory-generated function, and the native implementation return bit-identical results for all 5000 fixture values, so the same bound is the measured minimum for all three files. The observed ULP differences form a smooth, monotonically decaying distribution (373 cases at 1 ULP, tapering to a single case at 230 ULP), rather than a tight cluster with one outlier. For reference, the previous
140.0 * EPSrelative tolerance corresponds to roughly 140–280 ULP, so the new bound is consistent with the tolerance it replaces.Related Issues
This pull request has the following related issues:
math/base/specialpackages from relative tolerance testing to ULP difference testing (tracking issue) #11352Questions
No.
Other
Verification performed locally on
linux/x64, Node.js v22:make test TESTS_FILTER=".*/stats/base/dists/chi/pdf/.*"— 15242 assertions passing, 0 failing (test.pdf.js5115,test.factory.js5115,test.js3,test.native.js5009). The native add-on was compiled locally vianode-gyp rebuild, so thetest.native.jsassertions actually executed rather than being skipped.make lint-javascript-tests TESTS_FILTER=".*/stats/base/dists/chi/pdf/.*"— clean.Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
This PR was written by Claude Code running as an unattended scheduled task. The tolerance-to-ULP conversion mirrors the idiom of already-migrated packages in the same family (e.g.,
stats/base/dists/rayleigh/pdfandstats/base/dists/lognormal/pdf); the ULP bound search and the local verification runs were performed by the agent.@stdlib-js/reviewers
Generated by Claude Code